//
//  HealthViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/22.
//

#import "HealthViewController.h"
#import "MenstruatDateViewController.h"
#import "PreparePregnancyController.h"
#import "PregnancyingViewController.h"

@interface HealthViewController ()
@property(nonatomic,strong) UIView *topBackView;
@property(nonatomic,strong) MyLinearLayout *middle;
@end

@implementation HealthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setIsHideNavigationBar:YES];
    self.view.backgroundColor = BACKGROUNDCOLOR;
    
    
}


- (void)initSubviews {
    [super initSubviews];
    
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 180)];
    
    [backView az_setGradientBackgroundWithColors:@[[UIColor colorWithRGB:0xEAD2FF alpha:1.0],[UIColor colorWithRGB:0xF1E2FF alpha:0.81],[UIColor colorWithRGB:0xE5C9FF alpha:0]] locations:@[@0.0,@0.4,@1.0] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1.0)];
    [self.view addSubview:backView];
    
    MyLinearLayout *navView = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
    navView.myHorzMargin = 0;
    navView.gravity = MyGravity_Vert_Center | MyGravity_Horz_Between;
    navView.myHeight = 44;
    navView.myTop = StatusBarHeight;
    navView.padding = UIEdgeInsetsMake(0, 15, 0, 15);
    [self.view addSubview:navView];
    
    {
        UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backBtn setImage:UIImageMake(@"icon_arrow_left") forState:UIControlStateNormal];
        backBtn.mySize = CGSizeMake( 40, 40);
        backBtn.imageEdgeInsets = UIEdgeInsetsMake(10,10,10,10);
        [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        [navView addSubview:backBtn];
        
        UILabel *content = [UILabel createLabelText:@"女性健康" font:UIFontBoldMake(17) textColor:COLOR1515];
        content.mySize = kAutoSize;
        [navView addSubview:content];
        
        UIButton *right = [UIButton createButtonText :@"     " font:UIFontMake(14) textColor:COLOR1515];
        right.mySize = kAutoSize;
        [navView addSubview:right];
        
    }
    
    
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavigationContentTop, kScreenWidth, kScreenHeight - NavigationContentTop)];
    scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:scrollView];
    
    MyLinearLayout *root = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    root.myHorzMargin = 15;
    root.myTop = 15;
    root.padding = UIEdgeInsetsMake(0, 15, 0, 15);
    root.backgroundColor = COLOR_4;
    root.layer.cornerRadius = 15;
    [scrollView addSubview:root];
    
    MyLinearLayout *top = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
    top.myHorzMargin = 0;
    top.gravity = MyGravity_Vert_Center;
    top.myHeight = 56;
    [root addSubview:top];
    
    {
        UIImageView *imageView = [[UIImageView alloc]initWithImage:UIImageMake(@"watch_healthy")];
        imageView.mySize = CGSizeMake(24, 24);
        [top addSubview:imageView];
        
        UILabel *content = [UILabel createLabelText:@"女性健康提醒" font:UIFontMake(15) textColor:COLOR1515];
        content.myLeft = 10;
        content.myHeight = kAutoHeight;
        content.weight = 1;
        [top addSubview:content];
        
        UISwitch *sw = [[UISwitch alloc]init];
        sw.mySize = kAutoSize;
        sw.on = NO;
        sw.onTintColor = THEME_COLOR;
        [sw addTarget:self action:@selector(swClick:) forControlEvents:UIControlEventValueChanged];
        [top addSubview:sw];
    }

    [root addSubview:[self setAddLineTop:0]];
    
    MyLinearLayout *middle = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
    middle.myHorzMargin = 0;
    middle.gravity = MyGravity_Vert_Center;
    middle.myHeight = 56;
    [root addSubview:middle];
    middle.visibility = MyVisibility_Gone;
    self.middle = middle;
    
    [middle setTarget:self action:@selector(menstruatDateClick)];
    {
        UIImageView *imageView = [[UIImageView alloc]initWithImage:UIImageMake(@"unselect")];
        imageView.mySize = CGSizeMake(16, 16);
        [middle addSubview:imageView];
        
        MyLinearLayout *right = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
        right.weight = 1;
        right.myLeft = 10;
        right.subviewVSpace = 5;
        [middle addSubview:right];
        
        {
            UILabel *name = [UILabel createLabelText:@"记经期" font:UIFontMake(15) textColor:COLOR1515];
            name.mySize = kAutoSize;
            [right addSubview:name];
            
            UILabel *content = [UILabel createLabelText:@"经期7天，周期28天" font:UIFontMake(13) textColor:COLOR999];
            content.mySize = kAutoSize;
            [right addSubview:content];
        }
    }
    
//    [root addSubview:[self setAddLineTop:0]];
    
//    NSArray *array = @[@"备孕中",@"怀孕中"];
//    for (int i = 0; i < array.count; i++) {
//        MyLinearLayout *itemLay = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Horz];
//        itemLay.myHorzMargin = 0;
//        itemLay.gravity = MyGravity_Vert_Center;
//        itemLay.myHeight = 56;
//        itemLay.tag = 10 + i;
//        [root addSubview:itemLay];
//        [itemLay setTarget:self action:@selector(itemLayClick:)];
//
//        if(i==0)[root addSubview:[self setAddLineTop:0]];
//
//        {
//            UIImageView *imageView = [[UIImageView alloc]initWithImage:UIImageMake(@"unselect")];
//            imageView.mySize = CGSizeMake(16, 16);
//            [itemLay addSubview:imageView];
//
//            UILabel *name = [UILabel createLabelText:array[i] font:UIFontMake(15) textColor:COLOR1515];
//            name.myHeight = kAutoHeight;
//            name.weight = 1;
//            name.myLeft = 10;
//            [itemLay addSubview:name];
//        }
//
//
//    }
    
}

- (void)swClick:(UISwitch *)swich {
    
    if(swich.on){
        self.middle.visibility = MyVisibility_Visible;
    }else{
        self.middle.visibility = MyVisibility_Gone;
    }
    
}


- (void)menstruatDateClick {
    MenstruatDateViewController *vc = MenstruatDateViewController.new;
    [self showViewController:vc sender:self];
}

- (void)itemLayClick:(UIView *)view {
    NSInteger tag = view.tag  - 10;
    if(tag == 0){
        PreparePregnancyController *vc = PreparePregnancyController.new;
        [self showViewController:vc sender:self];
    }else{
        PregnancyingViewController *vc = PregnancyingViewController.new;
        [self showViewController:vc sender:self];
    }
}


@end
